var cheerio = require('cheerio');//引入dom操作库
var request = require('sync-request');//引入可访问其他网站的库


var res_in = request('GET', "http://career.job.sdu.edu.cn/eweb/jygl/index.so?modcode=jygl_zpxxck&subsyscode=zpfw&rklx=jyw&lmxhV=0402&type=ssoZxzpView&id=W9R6BRtBwQJyhBzCVcpUsB");
var $$ = cheerio.load(res_in.getBody());
var json_items = {};
json_items['company_website'] = $$('#zpxxtab>tbody>tr:nth-child(2)>td:nth-child(2)').text();
console.log( '公司的详细信息添加完成'+$$('#tab').length);
for (var ii = 0; ii < $$('#tab').length; ii++) {
    console.log( ii + '个岗位')
    json_items['job'] = {}
    json_items['job'][$$('#tab>tbody>tr:nth-child(1)>td:nth-child(2)').eq(ii).text().trim()] = {
        'number_of_people': $$('#tab>tbody>tr:nth-child(2)>td:nth-child(2)').eq(ii).text().trim(),
        'location': $$('#tab>tbody>tr:nth-child(2)>td:nth-child(4)').eq(ii).text().trim(),
        'language': $$('#tab>tbody>tr:nth-child(3)>td:nth-child(2)').eq(ii).text().trim(),
        'pay': $$('#tab>tbody>tr:nth-child(3)>td:nth-child(4)').eq(ii).text().trim(),
        'education_background': $$('#tab>tbody>tr:nth-child(4)>td:nth-child(2)').eq(ii).text().trim(),
        'major': $$('#tab>tbody>tr:nth-child(5)>td:nth-child(2)').eq(ii).text().trim(),
        'description': $$('#tab>tbody>tr:nth-child(6)>td:nth-child(2)').eq(ii).text().trim(),
    };
    console.log('完成第' + ii + '个公司的岗位信息');
}
console.log(json_items);